package com.linzm.behavioraltype.visitor12.computer;

import com.linzm.behavioraltype.visitor12.ComputerPartVisitor;

/**
 * @Author zimingl
 * @Date 2023/4/16 14:05
 * @Description: Computer
 */
public class Computer implements ComputerPart {
    ComputerPart[] parts;

    public Computer() {
        parts = new ComputerPart[]{new Mouse(), new Keyboard(), new Monitor()};
    }

    @Override
    public void accept(ComputerPartVisitor computerPartVisitor) {
        for (int i = 0; i < parts.length; i++) {
            parts[i].accept(computerPartVisitor);
        }
        computerPartVisitor.visit(this);
    }
}
